# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# If you are running on SunOS 5.x machines, uncomment the next line
GCCDIR = /auto/home-scf-22/csci402/testgnu/decstation-ultrix/bin/
LDFLAGS = -T newscript -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)

# if you aren't cross-compiling:
# GCCDIR =
# LDFLAGS = -N -T 0
# ASFLAGS =
# CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld
CPP = $(GCCDIR)cpp

INCDIR =-I../userprog -I../threads
CFLAGS = -G 0 -c $(INCDIR)

all: halt matmult sort testfiles halt2 halt3 theater theaterDriver matmultExec matmultFork sortExec sortFork

start.o: start.s ../userprog/syscall.h
	$(CPP) $(CPPFLAGS) start.s > strt.s
	$(AS) $(ASFLAGS) -o start.o strt.s
	rm strt.s

halt.o: halt.c
	$(CC) $(CFLAGS) -c halt.c
halt: halt.o start.o
	$(LD) $(LDFLAGS) start.o halt.o -o halt.coff
	../bin/coff2noff halt.coff halt

halt2.o: halt2.c
	$(CC) $(CFLAGS) -c halt2.c
halt2: halt2.o start.o
	$(LD) $(LDFLAGS) start.o halt2.o -o halt2.coff
	../bin/coff2noff halt2.coff halt2
	
halt3.o: halt3.c
	$(CC) $(CFLAGS) -c halt3.c
halt3: halt3.o start.o
	$(LD) $(LDFLAGS) start.o halt3.o -o halt3.coff
	../bin/coff2noff halt3.coff halt3

sort.o: sort.c
	$(CC) $(CFLAGS) -c sort.c
sort: sort.o start.o
	$(LD) $(LDFLAGS) start.o sort.o -o sort.coff
	../bin/coff2noff sort.coff sort

matmult.o: matmult.c
	$(CC) $(CFLAGS) -c matmult.c
matmult: matmult.o start.o
	$(LD) $(LDFLAGS) start.o matmult.o -o matmult.coff
	../bin/coff2noff matmult.coff matmult
	
matmultExec.o: matmultExec.c
	$(CC) $(CFLAGS) -c matmultExec.c
matmultExec: matmultExec.o start.o
	$(LD) $(LDFLAGS) start.o matmultExec.o -o matmultExec.coff
	../bin/coff2noff matmultExec.coff matmultExec
	
sortExec.o: sortExec.c
	$(CC) $(CFLAGS) -c sortExec.c
sortExec: sortExec.o start.o
	$(LD) $(LDFLAGS) start.o sortExec.o -o sortExec.coff
	../bin/coff2noff sortExec.coff sortExec
	
matmultFork.o: matmultFork.c
	$(CC) $(CFLAGS) -c matmultFork.c
matmultFork: matmultFork.o start.o
	$(LD) $(LDFLAGS) start.o matmultFork.o -o matmultFork.coff
	../bin/coff2noff matmultFork.coff matmultFork
	
sortFork.o: sortFork.c
	$(CC) $(CFLAGS) -c sortFork.c
sortFork: sortFork.o start.o
	$(LD) $(LDFLAGS) start.o sortFork.o -o sortFork.coff
	../bin/coff2noff sortFork.coff sortFork

testfiles.o: testfiles.c
	$(CC) $(CFLAGS) -c testfiles.c
testfiles: testfiles.o start.o
	$(LD) $(LDFLAGS) start.o testfiles.o -o testfiles.coff
	../bin/coff2noff testfiles.coff testfiles

	
theater.o: theater.c
	$(CC) $(CFLAGS) -c theater.c
theater: theater.o start.o
	$(LD) $(LDFLAGS) start.o theater.o -o theater.coff
	../bin/coff2noff theater.coff theater	
			
customer.o: customer.c
	$(CC) $(CFLAGS) -c customer.c
customer: customer.o start.o
	$(LD) $(LDFLAGS) start.o customer.o -o customer.coff
	../bin/coff2noff customer.coff customer
	
foodclerk.o: foodclerk.c
	$(CC) $(CFLAGS) -c foodclerk.c
foodclerk: foodclerk.o start.o
	$(LD) $(LDFLAGS) start.o foodclerk.o -o foodclerk.coff
	../bin/coff2noff foodclerk.coff foodclerk
	
manager.o: manager.c
	$(CC) $(CFLAGS) -c manager.c
manager: manager.o start.o
	$(LD) $(LDFLAGS) start.o manager.o -o manager.coff
	../bin/coff2noff manager.coff manager

	
ticketclerk.o: ticketclerk.c
	$(CC) $(CFLAGS) -c ticketclerk.c
ticketclerk: ticketclerk.o start.o
	$(LD) $(LDFLAGS) start.o ticketclerk.o -o ticketclerk.coff
	../bin/coff2noff ticketclerk.coff ticketclerk
	
tickettaker.o: tickettaker.c
	$(CC) $(CFLAGS) -c tickettaker.c
tickettaker: tickettaker.o start.o
	$(LD) $(LDFLAGS) start.o tickettaker.o -o tickettaker.coff
	../bin/coff2noff tickettaker.coff tickettaker
	
	
tech.o: tech.c
	$(CC) $(CFLAGS) -c tech.c
tech: tech.o start.o
	$(LD) $(LDFLAGS) start.o tech.o -o tech.coff
	../bin/coff2noff tech.coff tech
	
theaterDriver.o: theaterDriver.c
	$(CC) $(CFLAGS) -c theaterDriver.c
theaterDriver: theaterDriver.o start.o
	$(LD) $(LDFLAGS) start.o theaterDriver.o -o theaterDriver.coff
	../bin/coff2noff theaterDriver.coff theaterDriver

clean:
	rm -f *.o *.coff
